<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Memory Leak</title>
</head>
<body>
  <button id="grow">start</button>
  <script>
    var t = null;
    var replaceThing = function() {
      var o = t;
      var unused = function() {
        if (o) {
          console.log("hi");
        }
      }
      t = {
        longStr: new Array(1000000).fill('*'),
        someMethod: function() {
          console.log(1);
        }
      }
    }
    setInterval(replaceThing,100);
    var btnEl = document.getElementById('grow');
    btnEl.addEventListener('click', replaceThing);
  </script>
</body>
</html>